#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "authority.h"

// 全局数据存储
User users[MAX_USERS];
int userCount = 0;
// 添加用户
int addUser(int userID, const char *username, Role role)
{
    if (userCount >= MAX_USERS)
    {
        printf("User limit reached.\n");
        return 0;
    }
    users[userCount++] = (User){userID, "", role};
    strncpy(users[userCount - 1].username, username, sizeof(users[userCount - 1].username) - 1);
    printf("User added: %s (Role: %s)\n", username, role == ADMIN ? "Admin" : "User");
    return 1;
}
/**
 *  函数功能：验证用户身份
 *  输入参数：用户id
 *  返回值：0表示管理员，1表示用户,-1表示未找到
 *  输入范围：[0,MAX_USERS)
 **/
int checkUser(int userId)
{
    for (int i = 0; i < MAX_USERS; i++)
    {
        if (users[i].userID == userId) return users[i].role;
        break;
    }
    return -1;
}

void mainmenu()
{
    printf("");
}
